package com.hxzon.aixzsecretary.net;

import java.io.BufferedOutputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Date;

public class XmlClient extends Thread {
	private String IP;
	private int port = 5001;
	private String myname;
	private String myIP;
	private String subject;
	private String content;
	private Date time;

	public XmlClient(String IP, String myname, String myIP, String subject,
			String content, Date time) {
		this.IP = IP;
		this.myname = myname;
		this.myIP = myIP;
		this.subject = subject;
		this.content = content;
		this.time = time;
	}

	public void run() {
		Socket socket;
		try {
			socket = new Socket(IP, port);
			ObjectOutputStream dos = new ObjectOutputStream(
					new BufferedOutputStream(socket.getOutputStream()));
			// user data
			dos.writeUTF(myname);
			dos.flush();
			dos.writeUTF(myIP);
			dos.flush();
			dos.writeObject(new Date());
			dos.flush();
			// message data
			dos.writeUTF(subject);
			dos.flush();
			dos.writeUTF(content);
			dos.flush();
			dos.writeObject(time);
			dos.flush();
			// close
			dos.close();
		} catch (Exception e) {
		}
	}
}
